/**
 * @file   MethodInfo.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2013-05-19
 * @brief  DataBus Method Info.
 *
 * Copyright (C) 2013  Djuro Drljaca <djurodrljaca@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LIBDATABUS_COMMON_METHODINFO_H
#define LIBDATABUS_COMMON_METHODINFO_H

#include <QtCore/QString>
#include <QtCore/QList>
#include <DataBus/Common/Common.h>
#include <DataBus/Common/ValueInfo.h>

namespace DataBus
{
/**
 * @brief The MethodInfo class
 */
class DATABUSSHARED_EXPORT MethodInfo
{
public:
    /**
     * @brief Constructor for MethodInfo
     */
    MethodInfo();

    /**
     * @brief Constructor for MethodInfo
     *
     * @param id                    Method ID
     * @param name                  Method Name
     * @param parameterInfoList     Method Parameter Info list
     * @param returnValueInfoList   Method Return Value Info list
     */
    MethodInfo(const quint8 id,
               const QString &name,
               const QList<ValueInfo> &parameterInfoList,
               const QList<ValueInfo> &returnValueInfoList);

    /**
     * @brief Copy constructor for MethodInfo
     *
     * @param copyin    Original value
     */
    MethodInfo(const MethodInfo &copyin);

    /**
     * @brief Operator =
     *
     * @param rhs   Value on the right side of the operator =
     *
     * @return Value Info
     */
    MethodInfo & operator=(const MethodInfo &rhs);

    /**
     * @brief Check if Method Info is valid
     *
     * @retval true     Method Info is valid
     * @retval false    Method Info is invalid
     */
    bool isValid() const;

    /**
     * @brief Get Method ID
     *
     * @return Method ID
     */
    quint8 getId() const;

    /**
     * @brief Set Method ID
     *
     * @param id    Method ID
     */
    void setId(const quint8 id);

    /**
     * @brief Get Method Name
     *
     * @return Method Name
     */
    QString getName() const;

    /**
     * @brief Set Method Name
     *
     * @param name  Method Name
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setName(const QString &name);

    /**
     * @brief Get Parameter Info List
     *
     * @return Parameters Info list
     */
    QList<ValueInfo> getParameterInfoList() const;

    /**
     * @brief Set Parameter Info List
     *
     * @param parameterInfoList Parameter Info List
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setParameterInfoList(const QList<ValueInfo> &parameterInfoList);

    /**
     * @brief Get number of parameters
     *
     * @return Number of parameters
     */
    quint8 getNoOfParameters() const;

    /**
     * @brief Get Parameter Info by index
     *
     * @param index                 Parameter index
     *
     * @param[out] parameterInfo    Parameter Info
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool getParameterInfo(const quint8 index, ValueInfo *parameterInfo) const;

    /**
     * @brief Get Parameter Info by name
     *
     * @param name                  Parameter name
     *
     * @param[out] parameterInfo    Parameter Info
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool getParameterInfo(const QString &name, ValueInfo *parameterInfo) const;

    /**
     * @brief Add Parameter Info
     *
     * @param parameterInfo Parameter Info
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool addParameterInfo(const ValueInfo &parameterInfo);

    /**
     * @brief Get Return Value Info List
     *
     * @return Return Value Info list
     */
    QList<ValueInfo> getReturnValueInfoList() const;

    /**
     * @brief Set Return Value Info List
     *
     * @param returnValueInfoList Return Value Info List
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool setReturnValueInfoList(const QList<ValueInfo> &returnValueInfoList);

    /**
     * @brief Get number of return values
     *
     * @return Number of return values
     */
    quint8 getNoOfReturnValues() const;

    /**
     * @brief Get Return Value Info by index
     *
     * @param index                 Return Value index
     *
     * @param[out] returnValueInfo  Return Value Info
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool getReturnValueInfo(const quint8 index, ValueInfo *returnValueInfo) const;

    /**
     * @brief Get Return Value Info by name
     *
     * @param name                  Return Value name
     *
     * @param[out] returnValueInfo  Return Value Info
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool getReturnValueInfo(const QString &name, ValueInfo *returnValueInfo) const;

    /**
     * @brief Add Return Value Info
     *
     * @param returnValueInfo   Return Value Info
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool addReturnValueInfo(const ValueInfo &returnValueInfo);

private:
    /**
     * @brief Method ID
     */
    quint8 m_id;

    /**
     * @brief Method Name
     */
    QString m_name;

    /**
     * @brief Method Parameter Info list
     */
    QList<ValueInfo> m_parameterInfoList;

    /**
     * @brief Method Return Value Info list
     */
    QList<ValueInfo> m_returnValueInfoList;

    /**
     * @brief Valid flag
     */
    bool m_valid;
};
}

#endif // LIBDATABUS_COMMON_METHODINFO_H
